package pl.szlif.AChecker;

import pl.szlif.AChecker.AUtils.AccelerometerManager;
import pl.szlif.AChecker.AUtils.AccelerometrListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class ACheckerActivity extends Activity implements AccelerometrListener{
    /** Called when the activity is first created. */
	private static final String TAG = "Shake";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        AccelerometerManager.setActivity(this);
    }

	@Override
	public void onShake(String vector) {
		Toast.makeText(this, vector, Toast.LENGTH_LONG).show();
	}
	
	@Override
	protected void onResume() {
		if (AccelerometerManager.isSupported()) {
			AccelerometerManager.startListening(this);
		}else{
			Log.d(TAG, "Not supportedd.");
		}
		super.onResume();
	}
	
	@Override
	protected void onPause() {
		if (AccelerometerManager.isListening()) {
			AccelerometerManager.stopListening();
		}
		super.onPause();
	}
}